diff options
| author | real-zephex <[email protected]> | 2024-04-10 01:19:20 +0530 |
|---|---|---|
| committer | real-zephex <[email protected]> | 2024-04-10 01:19:20 +0530 |
| commit | e5935c15af0375240fa7c711dc99101fa48048be (patch) | |
| tree | e1807c8552c25b0f2f10d55dce59725606bb4b66 /src/app/anime/[id]/buttons.jsx | |
| parent | prolly the last update to dramalama. (diff) | |
| download | dramalama-e5935c15af0375240fa7c711dc99101fa48048be.tar.xz dramalama-e5935c15af0375240fa7c711dc99101fa48048be.zip | |
UI changes
Diffstat (limited to 'src/app/anime/[id]/buttons.jsx')
| -rw-r--r-- | src/app/anime/[id]/buttons.jsx | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/src/app/anime/[id]/buttons.jsx b/src/app/anime/[id]/buttons.jsx new file mode 100644 index 0000000..eac1884 --- /dev/null +++ b/src/app/anime/[id]/buttons.jsx @@ -0,0 +1,88 @@ +"use client"; + +import styles from "./info.module.css"; +import { useState } from "react"; +import { fetch_video_link } from "../videoLinkfetcher"; +import { MediaPlayer, MediaProvider } from "@vidstack/react"; +import "@vidstack/react/player/styles/base.css"; +import "@vidstack/react/player/styles/plyr/theme.css"; +import { + PlyrLayout, + plyrLayoutIcons, +} from "@vidstack/react/player/layouts/plyr"; + +export default function Button({ data2: info }) { + const [videoLink, setVideoLink] = useState(null); + + async function video(id) { + const link = await fetch_video_link(id); + if (link === undefined) { + alert("Sorry, but not links were found"); + } else { + setVideoLink(link); + console.log(videoLink); + } + } + + return ( + <main> + <h2 className={styles.buttonHeader}>Episodes: </h2> + <div className={styles.buttonContainer}> + {info && + info.episodes && + info.episodes.map((item, index) => ( + <button + className={styles.dramaButton} + key={index} + onClick={(event) => { + event.target.style.backgroundColor = + "var(--soft-purple)"; + video(item.id); + }} + > + {item.number} + </button> + ))} + </div> + + {videoLink && ( + <div + className={styles.videoPopUp} + id="popup" + onKeyDown={(event) => { + if (event.code === "Escape") { + setVideoLink(""); + } + }} + > + <div className={styles.video}> + <MediaPlayer + title="dramaPlayer" + src={videoLink} + aspectRatio="16/9" + load="eager" + className={styles.VideoPlayer} + playsInline + id="videoPlayer" + volume={0.2} + onQualityChange={(event) => + console.log("changed qualities", event) + } + > + <MediaProvider /> + <PlyrLayout icons={plyrLayoutIcons} /> + </MediaPlayer> + <button + className={styles.closeButton} + onClick={() => { + setVideoLink(""); + }} + > + Close + </button> + </div> + </div> + )} + </main> + ); +} |